<?php

namespace App\Controller\LazyCommon;

use App\Setting\LazyCommon\AdminLogSetting;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;

use Symfony\Component\HttpFoundation\Request;
use App\Base\BaseController;
use App\Entity\AdminLog as Entity;

/**
 * @route("/admin/")
 */
class AdminLogController extends BaseController
{

    /**
     * @route("AdminLog/add",name="AdminLogPreAdd")
     */
    public function add()
    {
        //通用代码
        $this->setSetting(new AdminLogSetting($this->getDoctrine()->getManager()));
        return $this->comAdd();
    }

    /**
     * @route("AdminLog/add/do",name="AdminLogDoAdd")
     *
     * @Method({"GET", "POST"})
     */
    public function doAdd(Request $request)
    {
        //私有代码
        $entity = new Entity();
        //通用代码
        $this->setSetting(new AdminLogSetting($this->getDoctrine()->getManager()));
        return $this->comDoAdd($request,$entity);
    }

    /**
     * @route("AdminLog/edit/{id}",name="AdminLogPreEdit")
     */
    public function edit(Entity $entity)
    {
        $this->setSetting(new AdminLogSetting($this->getDoctrine()->getManager()));
        return $this->comEdit($entity);
    }

    /**
     * @route("AdminLog/edit/{id}/do",name="AdminLogDoEdit")
     *
     * @Method({"GET", "POST"})
     */
    public function doEdit(Request $request,Entity $entity)
    {
        $this->setSetting(new AdminLogSetting($this->getDoctrine()->getManager()));
        return $this->comDoEdit($request,$entity);
    }

    /**
     * @route("AdminLog",name="AdminLogLists")
     */
    public function lists()
    {
        //私有部分
        $tools = array();

        //通用部分
        $this->setSetting(new AdminLogSetting($this->getDoctrine()->getManager()));
        return $this->comLists($tools);
    }


    /**
     * @route("AdminLog/tools",name="AdminLogTools")
     */
    public function tools(Request $request)
    {
        $this->setSetting(new AdminLogSetting($this->getDoctrine()->getManager()));
        return $this->comTools($request);
    }

}
